package com.example.train.api.controller.v1;

import com.example.train.app.service.DepartmentService;
import com.example.train.domain.entity.Department;
import com.example.train.domain.entity.Employee;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: chundong.huang@hand-china.com
 * @Date: 2023/3/25 15:40
 */
@RestController
@RequestMapping("/dep")
public class DepartmentController {

    private final DepartmentService departmentService;

    public DepartmentController(DepartmentService departmentService) {
        this.departmentService = departmentService;
    }

    @GetMapping("/list")
    public ResponseEntity<?> list(@RequestParam("id") Long id){
        return ResponseEntity.ok(departmentService.list(id));
    }

    @PostMapping("/del")
    public ResponseEntity<?> del(@RequestParam("id") Long id){
        return ResponseEntity.ok(departmentService.del(id));
    }

    @PostMapping("/insert")
    public ResponseEntity<?> insert(@RequestBody Department department){
        return ResponseEntity.ok(departmentService.insert(department));
    }

    @PostMapping("/update")
    public ResponseEntity<?> update(@RequestBody Department department){
        return ResponseEntity.ok(departmentService.update(department));
    }

}
